PICK SCREEN

This command will calculate a relative 3D coordinate from a 2D screen coordinate.

  Syntax
PICK SCREEN Screen X, Screen Y, Distance
  Parameters
Screen X
Integer
The x vector
Screen Y
Integer
The y vector
Distance
Float
The distance value you got from get pick distance()

  Returns

This command will calculate a relative 3D coordinate from a 2D screen coordinate

  Description

The additional Distance parameter indicates how far into the screen the 3D coordinate is to be calculated. The resulting 3D coordinate is not a world position, but a relative 3D vector from the current camera position. The world coordinate can be obtained by adding the camera position to the resulting vector. The resulting vector is generated internally and can be retrieved using the GET PICK VECTOR commands.

  Example Code
sync on : sync rate 60
make object plain 1,300,300
position object 1,0,-50,0
xrotate object 1,270
make object cube 2,100
set shadow shading on 2
set point light 0,-100,500,-100
position camera -200,0,-200
point camera 0,0,0
x#=0:y#=0:z#=0
do
set cursor 0,0
if mouseclick()=0 then pickmode=0
if mouseclick()>0
if pick object(mousex(),mousey(),2,2)>0
if pickmode=0
d#=get pick distance()
x#=get pick vector x():y#=get pick vector y():z#=get pick vector z()
print "object x ",x#," object y ",y#," object z ",z#," distance ",d#
inc pickmode
endif
endif
if pickmode=1
pick screen mousex(),mousey(),d#
dx#=x#-get pick vector x():dy#=y#-get pick vector y():dz#=z#-get pick vector z()
print dx#," ",dy#," ",dz#
endif
position object 2,dx#,dy#,dz#
endif
print x#," ",y#," ",z#
print "CLICK AND HOLD OBJECT TO DRAG"
sync
loop
end
  See also

BASIC3D Commands Menu
Index